package com.ktgj.customer.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ktgj.customer.domain.OrderPaymentRecord2Dto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.customer.service.IOrderPaymentRecord2Service;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 支付记录Controller
 * 
 * @author ruoyi
 * @date 2021-10-26
 */
@ControllerAdvice
@RestController
@RequestMapping("/record2")
public class TravelOrderPaymentRecord2Controller extends BaseController
{
    @Autowired
    private IOrderPaymentRecord2Service orderPaymentRecord2Service;

    /**
     * 查询支付记录列表
     */
    @PreAuthorize(hasPermi = "customer:record2:list")
    @GetMapping("/list")
    public TableDataInfo list(OrderPaymentRecord2Dto orderPaymentRecord2Dto)
    {
        startPage();
        List<OrderPaymentRecord2Dto> list = orderPaymentRecord2Service.selectOrderPaymentRecord2List(orderPaymentRecord2Dto);
        return getDataTable(list);
    }

    /**
     * 导出支付记录列表
     */
    @PreAuthorize(hasPermi = "customer:record2:export")
    @Log(title = "支付记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OrderPaymentRecord2Dto orderPaymentRecord2Dto) throws IOException
    {
        List<OrderPaymentRecord2Dto> list = orderPaymentRecord2Service.selectOrderPaymentRecord2List(orderPaymentRecord2Dto);
        ExcelUtil<OrderPaymentRecord2Dto> util = new ExcelUtil<OrderPaymentRecord2Dto>(OrderPaymentRecord2Dto.class);
        util.exportExcel(response, list, "支付记录数据");
    }

    /**
     * 获取支付记录详细信息
     */
    @PreAuthorize(hasPermi = "customer:record2:query")
    @GetMapping(value = "/{payId}")
    public AjaxResult getInfo(@PathVariable("payId") Long payId)
    {
        return AjaxResult.success(orderPaymentRecord2Service.selectOrderPaymentRecord2ById(payId));
    }

    /**
     * 新增支付记录
     */
    @PreAuthorize(hasPermi = "customer:record2:add")
    @Log(title = "支付记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderPaymentRecord2Dto orderPaymentRecord2Dto)
    {
        return toAjax(orderPaymentRecord2Service.insertOrderPaymentRecord2(orderPaymentRecord2Dto));
    }

    /**
     * 修改支付记录
     */
    @PreAuthorize(hasPermi = "customer:record2:edit")
    @Log(title = "支付记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderPaymentRecord2Dto orderPaymentRecord2Dto)
    {
        return toAjax(orderPaymentRecord2Service.updateOrderPaymentRecord2(orderPaymentRecord2Dto));
    }

    /**
     * 删除支付记录
     */
    @PreAuthorize(hasPermi = "customer:record2:remove")
    @Log(title = "支付记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{payIds}")
    public AjaxResult remove(@PathVariable Long[] payIds)
    {
        return toAjax(orderPaymentRecord2Service.deleteOrderPaymentRecord2ByIds(payIds));
    }
}
